<template>
	<!-- 下拉框 v-bind="$attrs" 小程序不支持-->
	<view class="un-popup-text" @click="open">
		<view><slot name="btn">打开弹窗</slot></view>
		<view class="icon"><uni-icons :type="show?'up':'down'" ></uni-icons></view>
	</view>
	
	<uni-popup ref="popup" @change ="onChange">
		<view class="un-popup-box">
			<view class="un-popup-title">
				<slot name="title">
					打开弹窗
				</slot>
			</view>
			<view class="un-popup-body">
				<slot name="body">
					<view>1底部弹出 Popup</view>
				</slot>
			</view>
		</view>
	</uni-popup>
</template>
<script>
	export default {
		name: "un-popup",
		// 子组件不继承本组件覆盖的属性：重写change事件
		inheritAttrs: false,
		props: {
		},
		data() {
			return {
				show:false,
				list: []
			};
		},
		created() {
			console.log('uni-popupuni-popupuni-popup');
		},
		methods: {
			 open(){
				// 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ，type 属性将失效 ，仅支持 ['top','left','bottom','right','center']
				this.$refs.popup.open('bottom')
			  },
			  close(){
			  	this.$refs.popup.close()
			   },
			  onChange(e){
				this.show = e.show
				this.$emit('change', e) 
			  }
		}
	}
</script>

<style lang="scss" scoped>
	.un-popup-text{
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
		.icon{
			padding-left: 10rpx;
		}
	}
	.un-popup-box{
		padding: 20rpx;
		border-radius:  16rpx 16rpx 0 0;
		background: #fff;
	}
	.un-popup-body{
		padding: 20rpx;
		border-radius:  16rpx 16rpx 0 0;
		background: #fff;
	}
	.un-popup-title{
		padding: 20rpx;
		font-size: 36rpx;
		font-weight: bold;
	}
</style>
